package team3.jobportal.controller;

import team3.jobportal.businesslogic.Company;
import team3.jobportal.businesslogic.Student;
import team3.jobportal.database.DBManager;
import team3.jobportal.utilities.Status.lastAction;

/* Is controller really needed in our application*/
public class ApplicationController {

	static ApplicationController controllerObject = null;
	static DBManager dbManagerObject = new DBManager();
    static lastAction status=lastAction.nill;
	
	public static ApplicationController getController() {
		if(controllerObject==null)
			controllerObject = new ApplicationController();
		return controllerObject;
	}

	public static DBManager getDBManager()
	{
		return dbManagerObject;
	}
	
	
	public static lastAction getStatus() {
		return status;
	}

	public boolean isStudentLoginValid(Student studentObj)
	{
		return dbManagerObject.isStudentLoginValid(studentObj);
	}
	
	public boolean isCompanyLoginValid(Company companyObj)
	{
		return dbManagerObject.isCompanyLoginValid(companyObj);
	}
	
	public boolean createStudentAccount(Student studentObj)
	{
		if(studentObj!=null)
		 if(!(studentObj.getEmailId().equals("")))
		 if(dbManagerObject.createStudentAccount(studentObj))
		 {
			 status = lastAction.studentAccountCreated;
			 return true;
		 }
		
		return false;
	}
	
	
}
